<template>
  <div class="news-item-content">
    <div class="left-content">
      <div class="title" @click="handleView">{{ item.title }}</div>
      <div class="subtitle" :title="item.subtitle">{{ item.subtitle }}</div>
      <p class="text-content">{{ item.remark }}</p>
      <span class="push-date">{{ item.releaseTime }}</span>
    </div>
    <div :class="{ 'no-img': !item.headUrl }" class="img-box">
      <img v-if="item.headUrl" class="img-inner" :src="item.headUrl" alt="" />
      <img
        v-else
        class="img-inner"
        src="./../assets/images/empty-headurl.png"
        alt=""
      />
      <!-- <el-image class="image-slot" v-else>
          <div slot="error" class="no-img-box">
              <i class="el-icon-picture-outline" style="font-size: 44px; color: #ccc"></i>
              <span>暂无封面</span>
          </div>
          
      </el-image> -->
      <i class="view-tag" @click="handleView">点击查看</i>
    </div>
    <div class="news-item-wrap">
      <div class="item-left">
        <img v-if="item.headUrl" class="img-inner" :src="item.headUrl" alt="" />
        <img
          v-else
          class="img-inner"
          src="./../assets/images/empty-headurl.png"
          alt=""
        />
      </div>
      <div class="item-right">
        <div class="title" @click="handleView">{{ item.title }}</div>
        <div class="subtitle" :title="item.subtitle">{{ item.subtitle }}</div>
        <p class="text-content">{{ item.remark }}</p>
        <p class="push-date">{{ item.releaseTime }}</p>
      </div>
    </div>
  </div>
</template>

<script>
import "swiper/css/swiper.min.css";
export default {
  // 组件名称
  name: "NewsItem",
  // 组件参数 接收来自父组件的数据
  props: {
    item: Object,
  },
  // 局部注册的组件
  components: {},
  // 组件状态值
  data() {
    return {};
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件方法
  methods: {
    handleView() {
      this.$emit("handleView", this.item);
    },
  },
  /**
   * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
   */
  created() {},

  mounted() {},
};
</script>
<style lang="less">
.news-item-content {
  .text-content {
    img,
    video {
      display: none;
    }
  }
  .no-img {
    .no-img-box {
      display: flex;
      flex-direction: column;
      align-items: center;
      color: #666;
    }
  }
}
</style>
<style lang="less" scoped>
@media (min-width: 769px) {
  .news-item-content {
    display: flex;
    padding-right: 34px;
    justify-content: space-between;
    cursor: pointer;

    .left-content {
      display: flex;
      flex-direction: column;
      padding: 35px 30px 48px;

      .title {
        margin-bottom: 13px;
        color: #3d6cb0;
        font-size: 24px;
        font-weight: 500;
        cursor: pointer;
        font-family: PingFangSC-Medium, PingFang SC;
      }

      .subtitle {
        margin-bottom: 12px;
        color: #37383d;
        font-size: 18px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        -webkit-line-clamp: 1;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: left;
      }

      .text-content {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        min-height: 76px;
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #37383d;
        line-height: 26px;
      }

      .push-date {
        font-weight: 400;
        color: #9597a0;
        margin-top: 11px;
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
      }
    }

    .img-box {
      width: 303px;
      height: 203px;
      flex-shrink: 0;
      position: relative;
      margin-top: 40px;
      border: 1px solid #eee;

      .img-inner {
        object-fit: cover;
        width: 100%;
        height: 100%;
      }

      .view-tag {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: -23px;
        font-style: normal;
        cursor: pointer;
        width: 170px;
        height: 48px;
        text-align: center;
        line-height: 48px;
        background: #4677b9;
        border-radius: 4px;
        font-size: 18px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #ffffff;
      }
    }

    .no-img {
      display: flex;
      justify-content: center;
      align-items: center;
      color: #666;
    }
  }
  .news-item-wrap {
    display: none;
  }
}

@media (max-width: 768px) {
  .left-content,
  .img-box {
    display: none;
  }
  .news-item-wrap {
    display: flex;
    margin: 0 0.12rem;
    padding: 0.12rem 0;
    border-bottom: 1px solid #e6e6e6;
    .item-left {
      width: 1.07rem;
      height: 0.94rem;
      margin-right: 0.1rem;
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
    .item-right {
      flex: 1;
      font-size: 0.1rem;
      line-height: 0.14rem;
      color: #9597a0;
      .title {
        height: 0.2rem;
        font-size: 0.14rem;
        font-weight: 500;
        color: #3d6cb0;
        line-height: 0.2rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
      }
      .subtitle {
        font-weight: 400;
        color: #37383d;
        margin: 0.05rem 0 0.12rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
      }
      .text-content {
        line-height: 0.14rem;
        margin-bottom: 0.08rem;
        height: 0.28rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }
      .push-date {
        font-weight: 400;
      }
    }
  }
}
</style>
